package com.mall.commons.utils;

import lombok.Data;

import java.io.Serializable;


@Data
public class R<T>  implements Serializable {

    private Integer code;
    private String message;
    private Object data;

    public static R success(String message,Object data){
        R r = new R();
        r.code = 200;
        r.message = message;
        r.data = data;
        return r;
    }

    public static R error(Integer code,String message){
        R r = new R();
        r.message = message;
        r.code = code;
        return r;
    }

    public static <T> R<T> success(T object) {
        R<T> r = new R<T>();
        r.data = object;
        r.code = 200;
        r.message = "操作成功";
        return r;
    }
}
